require("../../assets/css/normalize.css");
require("../../assets/css/reset.css");
require("../../assets/fonts/iconfont.css");
require("../../assets/css/tabbar.less");
require("../../assets/css/navbar.less");
require("./sport_run.less");
// 引入模块
let dom = require("../../utils/dom.js");
let axios = require("../../utils/axios.js");

document.addEventListener("DOMContentLoaded", function () {
	// 渲染navbar
	dom.navbar("run");
	// 渲染tabbar
	dom.tabbar("sport");
	// 1.点击GO按钮开启倒计时跑步

	dom.get("#goBtn").addEventListener("click", function () {
		dom.get("#mask").style.display = "block";
		// 开启倒计时
		let i = 3;
		setInterval(function () {
			i--;
			dom.get("#mask h1").textContent = i;
			if (i === 0) {
				location.href = "sport_running.html";
			}
		}, 1000);
	});
	// 2.渲染总里程数
	axios.get("/api/exercise").then(res => {
		console.log(res);
		dom.get("#runDate").textContent = res.data.data.sum7Meter / 1000;
	});
});
